package jdk;

import java.util.Arrays;
import java.util.Comparator;

/**
 * @program: algorithm
 * @description:
 * @author: 陈恩涛
 * @create: 2021-09-28 22:16
 **/
public class Strategy {
    public static void main(String[] args) {
        Integer[] data = { 9,1,2,8,4,3 };
        // 实现升序排序，返回-1放左边，1放右边，0保持不变
        Comparator<Integer> comparator = new Comparator<Integer>() {
            @Override
            public int compare(Integer o1, Integer o2) {
                if(o1 > o2) {
                    return 1;
                }else{
                    return -1;
                }};};
        Arrays.sort(data, comparator);
        System.out.println(Arrays.toString(data));

    }
}
